<?php 
// $data = json_decode($_GET['data'],true);
header("content-type:text/html;charset=utf8");
if (isset($_GET['code'])) {
    $code = $_GET['code'];
    $data = json_decode(urldecode($_GET['data']),true);
    $info = getToken($code);
}else{
	$data = $_GET['data'];
    $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2de38da107527240&redirect_uri=https://pay.hispot.cn/app/h5/movieDetails.php?data='.urlencode($data).'&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect';
    header('location:'.$url);
}

//获取微信Token信息
function getToken($code){
  $token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx2de38da107527240&secret=446fdd6335e31f0ceeaf63562ff03a4c&code=".$code."&grant_type=authorization_code";
  $data = json_decode(file_get_contents($token_url),true);
  return $data;
}
 ?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>支付确认</title>
	<link rel="stylesheet" type="text/css" href="css/reset.css"/>
	<link rel="stylesheet" type="text/css" href="css/style.css"/>
	<script type="text/javascript" src="js/rem.js"></script>
</head>
<body>
	<div class="wrapper flex-box flex-col">
		<!-- <header class="flex-box">
			<img src="img/images/pay_1.png"/>
			<span>购买影片</span>
		</header> -->
		<section>
			<div class="user flex-box flex-col">
				<div class="line"></div>
				<div class="flex-box">
					<dl class="flex1 flex-box">
						<dt><img src="<?php echo $data['user']['headimgurl']; ?>"/></dt>
						<dd><?php echo $data['user']['nickname']; ?></dd>
					</dl>
					<div class="toggle flex-box">
						<img src="img/images/pay_2.png"/>
						<span class="dot">切换账户</span>
					</div>
				</div>
			</div>
			<div class="shop">
				<h3 style="font-size: 40px">购买产品</h3>
				<div class="content flex-box">
					<dl class="flex-box movie flex1">
						<dt><img src="<?php echo $data['poster'] ?>"/></dt>
						<dd><?php echo $data['name'] ?></dd>
					</dl>
					<div class="price"><?php echo $data['price'] ?>元</div>
				</div>
			</div>
			<div class="question">
				<h3 style="font-size: 40px">说明</h3>
				<ul type="1" start="1" class="list" style="list-style-type:none">
					 <li style="font-size: 40px">付款的影片会与该登录账户绑定,支持者客户端登录观看已购买的付费影片。</li>
					<!-- <li style="font-size: 40px">如果你无法简洁的表达你的想法,那只说明你还不够了解它。</li>
					<li style="list-style: none;font-size: 40px">--阿尔伯特·爱因斯坦</li> -->
				</ul>
			</div>
		</section>
		<footer class="flex-box">
			<div class="payprice flex-box flex1">
				<p>支付金额</p>
				&nbsp;&nbsp;&nbsp;
				<p><?php echo $data['price'] ?>元</p>
			</div>
			<form action="../orderPay.php">
				<input type="hidden" name="movieName" value="<?php echo $data['name'] ?>">
				<input type="hidden" name="mid" value="<?php echo $data['mid'] ?>">
				<input type="hidden" name="uid" value="<?php echo $data['user']['uid'] ?>">
				<input type="hidden" name="openid" value="<?php echo $info['openid'] ?>">
				<input type="hidden" name="price" value="<?php echo $data['price'] ?>">
				<!-- <div class="paymoney">
					立即付款
				</div> -->
				<input type="submit" value='立即付款' class="paymoney">
			</form>
		</footer>
	</div>
</body>
</html>

<script src="js/jquery.1.12.js"></script>
<script>
	$(".dot").click(function() {
		alert('请在TV端首页-个人中心中进行切换账号操作');
	})
</script>